#include <vector>
#include <GL/gl.h>
#include "Image.h"
#include "d_Math.h"

using namespace std;
using namespace d_Math;

#ifndef PADSMESH_H
#define PADSMESH_H

struct PADSCam
{
	d_Vec3f vp;
	d_Vec3f d;
	d_Vec3f xa;
	d_Vec3f ya;
	float sx, sy, cx, cy, focal;
};

class PADSSplat
{
public:
	PADSSplat(){}
	d_Vec3f vp;
	d_Vec3f n;
	d_Vec3f c;
};

class PADSChart
{
public:
	PADSChart(PADSCam cam, Image *p, Image *n, Image *c, float dx, float dist, int bb_w, int bb_h, int bb_x, int bb_y);
	~PADSChart()
	{
		delete splats;
	}
	void draw();
	void drawNormals();
	d_Vec3f get_center();

private:
	PADSSplat *splats;
	int num_splats;
	GLfloat p_size[3];
};

class PADSMesh
{
public:
	PADSMesh(char *filename);
	~PADSMesh()
	{
		delete bb_w;
		delete bb_h;
		delete dist;
		delete dx;
		delete look_up;
		delete cameras;
		delete charts;
		delete p;
		delete n;
		delete c;
	}
	void draw();
	void drawCameras();
	int getNum_patches(){return num_patches;}
	d_Vec3f get_center();

	//Helper funcs for multiresolution mesh creation
	float get_realbbw(int cindex);
	float get_realbbh(int cindex);
	int get_minchart();
	float get_targetsize(int index);
	int get_treedepth(int index, float target_size);
	int get_top_of_chartw(int index, float size);
	int get_top_of_charth(int index, float size);
	int get_targetsize2(int index);
	int get_top_of_chartw2(int index, int size);
	int get_top_of_charth2(int index, int size);
	///////////////////////////////////////////////////////////////////////

//private:
	int *bb_w, *bb_h;
	int *bb_x, *bb_y;
	float *dist, *dx;
	int num_patches, num_cams;
	int *look_up;
	PADSCam *cameras;
	PADSChart **charts;
	Image **p;
	Image **n;
	Image **c;
};

#endif

